package com.sas.dao;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.sas.beans.Prestador;
import com.sas.dao.rowmapper.PrestadorRowMapper;

@Repository
@Transactional(propagation = Propagation.REQUIRED)
public class Dao {

	@Autowired
	NamedParameterJdbcTemplate jdbcTemplate;

	public void setJdbcTemplate(NamedParameterJdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	public List<Prestador> buscar() {

		String sql = "       SELECT  T1.COD_PRESTADOR,                   "
				+ "                   T1.DSC_QUALIFIC_PRESENTE,                   "
				+ "                   T1.DSC_ESPECIALID_QUALIFIC                  "
				+ "                   FROM SDE_QUALIFICACAO_QUALISS T1            "
				+ "                   WHERE T1.DSC_QUALIFIC_PRESENTE IS NOT NULL  "
				+ "                   AND T1.FLG_EXIBE_QUALIFIC = 'S'             "
				+ "                   AND T1.FLG_AUTZ_DIVULG = 'S'                ";
				//+"           AND  T1.COD_PRESTADOR= '00032602SPM0'              ";

		
		
		HashMap<String, String> hashMap = new HashMap<String, String>();
		List<Prestador> listaPrestador = jdbcTemplate.query(sql, hashMap,
				new PrestadorRowMapper());
		return listaPrestador;

	}

}
